package com.Controller;

import com.Service.TeacherService;
import com.entity.Teacher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/subject")
public class TeacherController {
    @Autowired
    private TeacherService teacherService;

    /**
     * 查询
     * @param teacher
     * @return
     */
    @RequestMapping(value = "/queryTeacher",method = RequestMethod.GET)
    public List<Teacher> queryTeacher(Teacher teacher){
        return teacherService.queryTeacher(teacher);
    }

    /**
     * 新增
     * @param teacher
     * @return
     */
    @RequestMapping(value = "/addTeacher",method = RequestMethod.POST)
    public int addTeacher(@RequestBody Teacher teacher){
        return teacherService.addTeacher(teacher);
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @RequestMapping(value = "/delTeacher/{id}",method = RequestMethod.DELETE)
    public int delTeacher(@PathVariable int id){
        return teacherService.delTeacher(id);
    }

    /**
     * 修改
     * @param teacher
     * @return
     */
    @RequestMapping(value = "/updateTeacher/{id}",method = RequestMethod.PUT)
    public int updateTeacher(@RequestBody Teacher teacher,@PathVariable int id){
        teacher.setTeacherId(id);
        return teacherService.updateTeacher(teacher);
    }
}
